package com.wfx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wfx.entity.Result;
import com.wfx.entity.ViewOrderItm;
import com.wfx.mapper.ViewOrderItmMapper;
import com.wfx.service.IViewOrderItmService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author zhu
 * @since 2021-01-27
 */
@Service
public class ViewOrderItmServiceImpl extends ServiceImpl<ViewOrderItmMapper, ViewOrderItm> implements IViewOrderItmService {
    @Autowired
    private ViewOrderItmMapper viewOrderItmMapper;
    //订单明细
    @Override
    public Result<ViewOrderItm> item(String orderId) {
        if (orderId == null||"".equals(orderId)) {
            return new Result<>(false, "参数异常");
        }
//        QueryWrapper<ViewOrderItm> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("order_id", orderId);
//        List<ViewOrderItm> viewOrderItms = viewOrderItmMapper.selectList(queryWrapper);
        List<ViewOrderItm> item = viewOrderItmMapper.item(orderId);
        System.out.println(item);
        if (item.isEmpty()) {
            return new Result<>(false, "无数据");
        }
        return new Result(true, "数据请求成功", item);
    }

}
